
    /********************************************************/
    /*                                                      */
    /*                                                      */
    /*         Copyright (C), 2001  SEIKO EPSON Corp.       */
    /*         ALL RIGHTS RESERVED                          */
    /*                                                      */
    /*                                                      */
    /*  file name : longjmp.c                               */
    /*                                                      */
    /*  Revision history                                    */
    /*    2001/08/09    first release       T.Tazaki        */
    /*    2001/08/21    bug fix             T.Tazaki        */
    /*    2001/11/21    chage to GNU33(LInux) T.Tazaki      */
    /*                                                      */
    /********************************************************/

#ifdef      UNIX
#include    "stdlib.h"
#include    "setjmp.h"
#else
#include    <stdlib.h>
#include    <setjmp.h>
#endif

/* void longjmp(jmp_buf *JmpBuf, int ReturnValue) 2001.08.21 */
void longjmp(jmp_buf JmpBuf, int ReturnValue)
{
	asm("	ld.w	%r0,[%r6]+");
	asm("	ld.w	%r1,[%r6]+");
	asm("	ld.w	%r2,[%r6]+");
	asm("	ld.w	%r3,[%r6]+");
	asm("	ld.w	%r5,[%r6]+");	/* psr */
	asm("	ld.w	%r8,[%r6]+");	/* sp  */
	asm("	ld.w	%r9,[%r6]+");	/* alr */
	asm("	ld.w	%r10,[%r6]+");	/* ahr */
	asm("	ld.w	%r11,[%r6]+");	/* [%sp+0x00] return address */
	asm("	ld.w	%psr,%r5");
	asm("	ld.w	%sp, %r8");
	asm("	ld.w	%alr,%r9");
	asm("	ld.w	%ahr,%r10");
	asm("	ld.w	[%sp+0x00],%r11");
	asm("	cmp	%r7,0x00");	/* if (ReturnValue == 0) ReturnValue = 1 */
	asm("	jrne	RetLongJmp");
	asm("	ld.w	%r7,0x01");
	asm("RetLongJmp:");
	asm("	ret.d");
	asm("	ld.w	%r4,%r7");
}